All Articles

Driving Performance - 10 Practical Guides to Web Optimization For a Higher Lighthouse Score

Improving web performance is not just about faster page loads. It’s about delivering a smoother, more accessible user experience across devices.

Driving Performance - 10 Practical Guides to Web Optimization For a Higher Lighthouse Score

Driving Performance - 10 Practical Guides to Web Optimisation For a Higher Lighthouse Score

Improving web performance is not just about faster page loads. It’s about delivering a smoother, more accessible user experience across devices. Google’s Lighthouse is a widely accepted tool to benchmark that experience. This guide outlines ten actionable practices frontend developers can apply today to improve Lighthouse scores in real-world applications using React and TypeScript.

1. Optimise Image Delivery

Large, unoptimised images are a common cause of poor performance scores. Convert assets to modern formats like WebP or AVIF. Use responsive images with srcset and sizes to serve appropriately sized versions based on screen resolution.

Example:

<img
  srcSet="/img/banner-800w.webp 800w, /img/banner-1600w.webp 1600w"
  sizes="(max-width: 768px) 800px, 1600px"
  src="/img/banner-1600w.webp"
  alt="Promotional banner"
/>

2. Use Lazy Loading for Offscreen Content

Lazy loading defers the loading of images and components not visible in the initial viewport. This improves initial load time and time to interactive.

Use native loading="lazy" for images, and dynamic import() in React for route-level or component-level code splitting.

const Chart = React.lazy(() => import("./Chart"))

3. Minimise JavaScript Bundle Size

Analyse your bundle using Webpack Bundle Analyzer. Remove unused dependencies. Prefer lighter alternatives where possible (e.g., date-fns instead of moment.js). Use tree-shaking and ensure dead code is eliminated by setting sideEffects: false in package.json.

4. Leverage Browser Caching

Set proper cache headers for static assets. In Next.js, you can define headers in next.config.js to control cache behaviour.

headers() {
  return [
    {
      source: '/(.*)',
      headers: [
        {
          key: 'Cache-Control',
          value: 'public, max-age=31536000, immutable',
        },
      ],
    },
  ];
}

5. Use Static Rendering Where Possible

Server-Side Rendering (SSR) adds flexibility, but static rendering (SSG) offers better performance and reliability. In Next.js, use getStaticProps instead of getServerSideProps when data does not change per request.

6. Eliminate Render-Blocking Resources

Reduce critical CSS and avoid loading large fonts or third-party scripts early. Use font-display: swap and defer non-critical JS using async or defer attributes.

7. Prioritise Core Web Vitals

Monitor metrics like Largest Contentful Paint (LCP), First Input Delay (FID), and Cumulative Layout Shift (CLS). Use the web-vitals library or tools like SpeedCurve to track these in production.

import { getCLS, getFID, getLCP } from "web-vitals"
getCLS(console.log)
getFID(console.log)
getLCP(console.log)

8. Use a CDN for Static Assets

Content Delivery Networks (CDNs) reduce latency by serving assets from geographically distributed servers. Tools like Vercel and Cloudflare automatically enable CDN support for frontend assets.

9. Avoid Excessive Third-Party Scripts

Third-party scripts (ads, analytics, widgets) can significantly delay rendering. Audit what is necessary. Load scripts lazily or via a tag manager with clear control over load timing.

10. Monitor and Iterate

Performance is not static. Set up continuous monitoring using Lighthouse CI or PageSpeed Insights. Incorporate performance budgets in CI pipelines to prevent regressions over time.

Summary

Performance optimisation is a moving target. By integrating these ten strategies into your development workflow, you can systematically raise your Lighthouse score, improve real-world user experiences, and ensure your frontend remains competitive. Focus on measurement, make small but consistent improvements, and treat performance as a shared responsibility across the team.

Published Nov 20, 2023

Hey there! I'm Hemense, a Frontend Developer with 4 years of experience developing scalable, high-performance web applications in SaaS, fintech, ERP, and AI-driven solutions. I am skilled in building component-driven architectures, improving user engagement, reducing churn, and optimizing platform performance for revenue growth. I have experience with React, TypeScript and its ecosystem. I am passionate about data- driven development, design systems, and engineering best practices to drive impactful user experiences.